/*******************************************************************************
New Unit Technologies, a division of DBI, LLC.

Created for CS450 at West Virginia University, Fall 2003

Developers:	Matthew Bradley
		Andrew Lowery
		Richard Paletta
		J. Ryan Sigler

File name: main.c
*******************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include "pcb.h"
#include "mpx.h"
#include "mpx_supt.h"
#include "int_supt.h"

PCB *running;
queue *READY_QUEUE;
queue *SUS_READY_QUEUE;
queue *BLOCKED_QUEUE;
queue *SUS_BLOCKED_QUEUE;

void main(void)
{
	printf("Initializing MPX\n");         				//Initialize MPX
	sys_init(MODULE_R1+MODULE_R2+MODULE_R3+MODULE_R4);
    
    sys_set_vec(sys_call);
    
	printf("Initializing Process Queues\n");

	/* ALLOCATE  and INITIALIZE QUEUES */

	READY_QUEUE = (queue *) sys_alloc_mem((size_t) sizeof(queue));
	initialize(READY_QUEUE);
	
	READY_QUEUE->count = 0;

	SUS_READY_QUEUE = (queue *) sys_alloc_mem((size_t) sizeof(queue));
	initialize(SUS_READY_QUEUE);
	
	SUS_READY_QUEUE->count = 0;

	BLOCKED_QUEUE = (queue *) sys_alloc_mem((size_t) sizeof(queue));
	initialize(BLOCKED_QUEUE);
	
	BLOCKED_QUEUE->count = 0;

	SUS_BLOCKED_QUEUE = (queue *) sys_alloc_mem((size_t) sizeof(queue));
	initialize(SUS_BLOCKED_QUEUE);
	
	SUS_BLOCKED_QUEUE->count = 0;

	printf("Loading NUT Interface\n");
	comhan();                        				 //Load comhan

	printf("Cleaning up system. Exiting MPX\n");
	sys_exit();                           				 //Exit MPX
}
